package leetcode2;

import java.sql.SQLOutput;
import java.text.ParseException;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

public class NumArray {
    private int[] nums;
    private int[] sums;

    public NumArray(int[] nums) {
        int n = nums.length;
        this.nums = nums;
        sums = new int[n + 1];
        for (int i = 0; i < n; i++) {
            sums[i + 1] = sums[i] + nums[i];
        }
    }

    public int sumRange(int left, int right) {
        return sums[right + 1] - sums[left];
    }

    public static void main(String[] args) throws ParseException {
        Set<Integer> integerSet = new HashSet<>();
        integerSet.add(1);
        integerSet.add(2);
        integerSet.add(5);
        integerSet.add(4);
        AtomicBoolean isContainFive = new AtomicBoolean(false);
        integerSet.forEach(item -> {
            if (item == 5) {
                isContainFive.set(true);
            }
        });
        System.out.println(isContainFive.get());
    }
}
